#include<stdio.h>
void SameCount(int arrA[], int arrB[], int A, int B) {
	int i = 0;
	int j = 0;
	int count = 0;
	for (i = 0; i < A; i++) {
		for (j = 0; j < B; j++) {
			if (arrA[i] == arrB[j]) {
				count++;
			}
		}
	}
	printf("%d",count);
}
int main() {
	void Setarr(int i, int arr[]);
	void SameCount(int arrA[], int arrB[], int A, int B);
	int A = 0;
	int B = 0;
	scanf_s("%d %d", &A, &B);
	int arrA[20];
	int arrB[20];
	int i = 0;
	for (i = 0; i < A; i++) {
		scanf_s("%d", &arrA[i]);
	}
	i = 0;
	for (i = 0; i < B; i++) {
		scanf_s("%d", &arrB[i]);
	}
	SameCount(arrA, arrB, A, B);
}
